/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.project.controller;

import java.io.FileInputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

/**
 *
 * @author thetrungbk
 */
public class DatabaseConnection {

    public static Connection getConnection()
            throws SQLException, IOException {
        Properties props = new Properties();
        FileInputStream in = new FileInputStream("InfomationDatabase.properties");
        props.load(in);
        in.close();

        String drivers = props.getProperty("jdbc.drivers");
        if (drivers != null) {
            System.setProperty("jdbc.drivers", drivers);
        }
        String url = props.getProperty("jdbc.url");
        String username = props.getProperty("jdbc.username");
        String password = props.getProperty("jdbc.password");

        return DriverManager.getConnection(url, username, password);
    }
}
